package com.ruoyi.web.controller.production.stroma;

import java.util.List;

import com.ruoyi.common.annotation.PropertyInject;
import com.ruoyi.common.enums.InjectType;
import io.swagger.annotations.Api;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.production.domain.stroma.StromaAmount;
import com.ruoyi.production.service.stroma.IStromaAmountService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 基质量Controller
 *
 * @author ruoyi
 * @date 2021-07-12
 */
@RestController
@RequestMapping("/production/stromaAmount")
@Api(value = "基质量",tags = "基质量相关API")
public class StromaAmountController extends BaseController
{
    @Autowired
    private IStromaAmountService stromaAmountService;

    /**
     * 查询基质量列表
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:list')")
    @GetMapping("/list")
    public TableDataInfo list(StromaAmount stromaAmount)
    {
        startPage();
        List<StromaAmount> list = stromaAmountService.selectStromaAmountList(stromaAmount);
        return getDataTable(list);
    }

    /**
     * 导出基质量列表
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:export')")
    @Log(title = "基质量", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(StromaAmount stromaAmount)
    {
        List<StromaAmount> list = stromaAmountService.selectStromaAmountList(stromaAmount);
        ExcelUtil<StromaAmount> util = new ExcelUtil<StromaAmount>(StromaAmount.class);
        return util.exportExcel(list, "基质量数据");
    }

    /**
     * 获取基质量详细信息
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:query')")
    @GetMapping(value = "/{stromaAmountId}")
    public AjaxResult getInfo(@PathVariable("stromaAmountId") Long stromaAmountId)
    {
        return AjaxResult.success(stromaAmountService.selectStromaAmountById(stromaAmountId));
    }

    /**
     * 新增基质量
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:add')")
    @Log(title = "基质量", businessType = BusinessType.INSERT)
    @PostMapping
    @PropertyInject(type = InjectType.Insert)
    public AjaxResult add(@RequestBody StromaAmount stromaAmount)
    {
        return toAjax(stromaAmountService.insertStromaAmount(stromaAmount));
    }

    /**
     * 修改基质量
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:edit')")
    @Log(title = "基质量", businessType = BusinessType.UPDATE)
    @PutMapping
    @PropertyInject(type = InjectType.Update)
    public AjaxResult edit(@RequestBody StromaAmount stromaAmount)
    {
        return toAjax(stromaAmountService.updateStromaAmount(stromaAmount));
    }

    /**
     * 删除基质量
     */
    @PreAuthorize("@ss.hasPermi('production:stromaAmount:remove')")
    @Log(title = "基质量", businessType = BusinessType.DELETE)
	@DeleteMapping("/{stromaAmountIds}")
    public AjaxResult remove(@PathVariable Long[] stromaAmountIds)
    {
        return toAjax(stromaAmountService.deleteStromaAmountByIds(stromaAmountIds));
    }
}
